import factory from './schema-factory';


export default factory({
    type: 'page',
    body: {
        type: 'wrapper',
        className: 'container w-xxl w-auto-xs',
        body: {
            type: 'form',
            className: 'm-t-lg',
            wrapWithPanel: false,
            redirect: '/user/team-settings',
            api: '/api/register',
            mode: 'horizontal',
            horizontal: {
                left: 'col-sm-4',
                right: 'col-sm-8',
                offset: 'col-sm-offset-4'
            },
            controls: [
                {
                    type: 'hidden',
                    name: 'org_code'
                },
                {
                    type: 'plain',
                    text: '团队注册',
                    className: 'navbar-brand block text-2x m-t no-shadow m-b'
                },

                {
                    type: 'panel',
                    className: 'no-border no-bg',
                    bodyClassName: 'no-padder',
                    formClassName: 'list-group',
                    mode: 'normal',
                    controls: [
                        {
                            type: 'text',
                            name: 'name',
                            placeholder: '团队名称',
                            className: 'list-group-item m-l-none m-r-none',
                            inputClassName: 'no-border no-shadow  p-l-none p-r-none',
                            required: true,
                            label: false,
                        },

                        {
                            type: 'text',
                            name: 'username',
                            placeholder: '团队账号',
                            validations: 'isAlphanumeric,minLength:6',
                            className: 'list-group-item m-l-none m-r-none',
                            inputClassName: 'no-border no-shadow  p-l-none p-r-none',
                            required: true,
                            label: false,
                        },

                        {
                            type: 'text',
                            name: 'phone',
                            placeholder: '手机号',
                            validations: 'isPhone',
                            className: 'list-group-item m-l-none m-r-none',
                            inputClassName: 'no-border no-shadow  p-l-none p-r-none',
                            required: true,
                            label: false,
                        },

                        {
                            label: "短信验证码",
                            type: "phone-code",
                            name: "code",
                            sendApi: 'post:/api/login/verifyphone?type=1',
                            phoneFieldName: "phone",
                            className: 'list-group-item m-l-none m-r-none',
                            inputClassName: 'no-border no-shadow  p-l-none p-r-none',
                            required: true,
                            // label: false,
                        },

                        {
                            type: 'password',
                            name: 'password',
                            placeholder: '团队密码',
                            className: 'list-group-item m-l-none m-r-none',
                            validations: 'minLength:6',
                            inputClassName: 'no-border no-shadow  p-l-none p-r-none',
                            required: true,
                            label: false,
                        },

                        {
                            type: 'password',
                            name: 'password_confirmation',
                            placeholder: '确认密码',
                            className: 'list-group-item m-l-none m-r-none',
                            inputClassName: 'no-border no-shadow  p-l-none p-r-none',
                            required: true,
                            label: false
                        },

                    ]
                },

                {
                    type: "select",
                    name: "parent_id",
                    label: "上级团队",
                    labelClassName: 'text-left',
                    autoComplete: "/api/team/term?term=${term}&org_code=${org_code}",
                    placeholder: "上级团队（选填）",
                    cache: false
                },

                {
                    type: 'checkbox',
                    option: '我已阅读并授权<a target="_blank" href="/agreement"><%= window.vars && window.vars.orgName || "志多星" %>的团队用户协议</a>',
                    name: 'aggree',
                    required: true,
                    noOffset: true,
                    trueValue: '1',
                    falseValue: '',
                    validationErrors: {
                        isDefaultRequiredValue: '请阅读《<%= window.vars && window.vars.orgName || "志多星" %>的团队用户协议》'
                    }
                },

                {
                    type: 'submit',
                    block: true,
                    label: '注册',
                    size: 'lg',
                    primary: true,
                    noOffset: true
                },

                {
                    type: 'tpl',
                    tpl: '<p class="text-center"><small>已拥有账号？</small></p>'
                },

                {
                    type: 'button',
                    block: true,
                    label: '登录',
                    size: 'lg',
                    actionType: 'link',
                    link: '/login/${params.org_code}',
                    noOffset: true
                },

                {
                    type: 'tpl',
                    className: 'text-center',
                    tpl: `
                    <p>
                    <small class="text-muted"><%= window.vars && window.vars.orgName || "志多星" %>管理系统<br>© 2017</small>
                    </p>
                    `
                }

            ]
        }
    }
}, '团队注册');
